# -*- coding: utf-8 -*-
import sys
class Req(object):
    '''
    # class Req
    # a Req consists of 3 parts(unit_info,data_info,fetch_info) and _id:
    # _id
    # unit_info:tell what unit to use
        ->start {'unit_name':'SampleJudge'}
    # data_info:store all the dataset in the whole procedure
        ->start
        {
            "dataset_from_commit":{
            "dataset_usage":"dataset_from_commit",
            "field_name_list"==['uid','pid','tid','ans'],
            "uid_pid_tid_ans_list":[{'uid':1,'pid':1,'tid':1,'ans':1},{...}]
            }
        }
        -->after Fetcher
        {
            "dataset_from_commit":{
                "dataset_usage":"dataset_from_commit",
                "field_name_list"==['uid','pid','tid','ans'],
                "uid_pid_tid_ans_list":[{'uid':1,'pid':1,'tid':1,'ans':1},{...}]
            }
            -------add in Fetcher
            "dataset_uid_history_ans":{
                "dataset_usage":"dataset_to_unit",
                "field_name_list"==['uid','pid','tid','ans'],
                "data_list_name":"pid_tid_ans_list",
                "data_list":[
                    {"uid":5520,
                    #todo convert a dict {'pid':1,'tid':1,'ans':1} to a hash
                    "pid_tid_ans_list":[{'pid':1,'tid':1,'ans':1},{'pid':1,'tid':1,'ans':-1},{...}]
                    },
                ]
            }
            "dataset_pid_history_ans":{
                "dataset_usage":"dataset_to_unit",
                "field_name_list":['uid','pid','tid','ans'],
                "data_list_name":"tid_uid_ans_list",
                "data_list":[
                    {"pid":1320,
                    "tid_uid_ans_list":[{'tid':1,'uid':1,'ans':1},{'tid':1,'uid':2,'ans':-1},{...}]
                    },
                ]
            }
            "dataset_tid_history_ans":{
                "dataset_usage":"dataset_to_unit","yes_num":10,"no_num":11
                "field_name_list":['tid','pid','yes_num','no_num'],
                "data_list_name":"pid_num_list",
                "data_list":[
                    {"tid":23
                    "pid_num_list":[{'pid':1,'yes_num':23,'no_num':12},{'pid':2,'yes_num':12,'no_num':98},{...}]
                    },
                ]
            }
            -------add in Fetcher
        -->after unit
        {
            "dataset_from_commit":{
                "dataset_usage":"dataset_from_commit",
                "field_name_list"==['uid','pid','tid','ans'],
                "uid_pid_tid_ans_list":[{'uid':1,'pid':1,'tid':1,'ans':1},{...}]
            }
            -------add in Fetcher
            "dataset_uid_history_ans":{~~~~~~coll:uid_pid_tid_ans_ase_coll
                "dataset_usage":"dataset_to_unit",
                "field_name_list"==['uid','pid','tid','ans'],
                "data_list_name":"pid_tid_ans_list",
                "data_list":[
                    {"uid":5520,
                    #todo convert a dict {'pid':1,'tid':1,'ans':1} to a hash
                    "pid_tid_ans_list":[{'pid':1,'tid':1,'ans':1},{'pid':1,'tid':1,'ans':-1},{...}]
                    },{...}
                ]
            }
            "dataset_pid_history_ans":{~~~~~~coll:uid_pid_tid_ans_ase_coll
                "dataset_usage":"dataset_to_unit",
                "field_name_list":['uid','pid','tid','ans'],
                "data_list_name":"tid_uid_ans_list",
                "data_list":[
                    {"pid":1320,
                    "tid_uid_ans_list":[{'tid':1,'uid':1,'ans':1},{'tid':1,'uid':2,'ans':-1},{...}]
                    },
                ]
            }
            "dataset_tid_history_ans":{~~~~~~coll:tid_pid_num_coll
                "dataset_usage":"dataset_to_unit","yes_num":10,"no_num":11
                "field_name_list":['tid','pid','yes_num','no_num'],
                "data_list_name":"pid_num_list",
                "data_list":[
                    {"tid":23
                    "pid_num_list":[{'pid':1,'yes_num':23,'no_num':12},{'pid':2,'yes_num':12,'no_num':98},{...}]
                    },
                ]
            }
            -------add in Fetcher
            -------add in Unit
            "dataset_ans_assessment":{~~~~~~coll:uid_pid_tid_ans_ase_coll
                "dataset_usage":"dataset_to_saver",
                "coll_name":"uid_pid_tid_ans_ase_coll",
                "field_filter_list":['uid','pid','tid','ans'],---->to find the doc to update
                "field_update_list":['ase'],
                "field_name_list":['uid','pid','tid','ans','ase'],
                "data_list_name":"uid_pid_tid_ans_ase_list",
                "uid_pid_tid_ans_ase_list":[{'uid':1,'pid':1,'tid':1,'ans':1,'ase':1},{...}]
            }
            "dataset_pid_judge":{~~~~~~coll:pid_truetid_coll
                "dataset_usage":"dataset_to_saver",
                "coll_name":"uid_pid_tid_ans_ase_coll",
                "field_filter_list":['pid'],---->to find the doc to update
                "field_update_list":['true_tid'],
                "field_name_list":['pid','true_tid'],
                "data_list_name":"pid_truetid_list",
                "pid_truetid_list":[{'pid':1,'true_tid':1},{...}]
            }
            -------add in Unit
        }
    # fetch_info:tell the fetcher what data to fetch
        -->after ReqFactory
        {"fetch_scheme":'SampleJudge',"fetch_param_set":{uid_list':[1,2],'pid_list':[1,2],'tid_list':[1,2]}}
        -->after Fetcher
        {"fetch_field__list"==['uid','pid','tid','ans']}
    '''
    def __init__(self,id,input_info):

        self._id=id
        self.unit_info={}
        self.fetch_info={}
        self.data_info={}
        self.data_info["dataset_from_commit"]=input_info["dataset_from_commit"]
        self.unit_info["unit_name"]=input_info["unit_name"]

